home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / doc / plot10.pro < prev    next >
Text File  |  1997-07-08  |  1KB  |  49 lines

  1. ; This file compiles to simple routines that illustrate the use
  2. ; of the CURSOR procedure. The examples come from Chapter 10, 
  3. ; "Plotting", of _Using IDL_.
  4.  
  5. ; The first routine draws lines on a window until the right
  6. ; mouse button is clicked.
  7.  
  8. PRO draw
  9.  
  10. ; Start with a blank screen.
  11.  
  12. ERASE    
  13.  
  14. ; Get the initial point in normalized coordinates.
  15.  
  16. CURSOR, X, Y, /NORMAL, /DOWN    
  17.  
  18. ; Repeat until the right button is pressed.
  19.  
  20. WHILE (!MOUSE.button NE 4) DO BEGIN    
  21.     CURSOR, X1, Y1, /NORM, /DOWN    ; Get the second point.
  22.     PLOTS,[X,X1], [Y,Y1], /NORMAL    ; Draw the line.
  23.     X = X1 & Y = Y1                    ; Make the current second point
  24.                                         ;be the new first.
  25. ENDWHILE
  26. END
  27.  
  28. ; The second routine allows you to position a text label on
  29. ; an existing window.
  30.  
  31. PRO LABEL, TEXT     
  32.  
  33. ; Text is the string to be written on the screen.
  34. ; Ask the user to mark the position.
  35.  
  36. PRINT, 'Use the mouse to mark the text position:'
  37.  
  38. ; Get the cursor position after press ing any button.
  39.  
  40. CURSOR, X, Y, /NORMAL, /DOWN    
  41.  
  42. ; Write the text at the specified position. The NOCLIP keyword is 
  43. ; used to ensure that the text will appear even if it is outside
  44. ; the plotting region.
  45.  
  46. XYOUTS, X, Y, TEXT, /NORMAL, /NOCLIP    
  47.  
  48. END
  49.